/**
 * Created by guobaogang on 2018/9/13.
 */
import React, {Component} from 'react';
import {toast, ajax, promptBox, cacheTools} from 'nc-lightapp-front';
import './index.less';
import EmptyImg from '../../../../../hrpub/common/components/emptyImg/index';
import Header from '../components/Header'
import TableList from '../components/tableList'
import CardList from '../components/cardList'
import FileUpload from '../components/fileUpload'
import AddNew from '../components/AddNew'
import IsMac from '../../../../public/functions/isMac'
import {fixedCol, getAppPageConfig} from "src/hrpub/common/utils/utils";
import WpsModal from 'src/hrpub/common/components/wpsPreModel';
const appcode = getAppPageConfig().appcode, pagecode = getAppPageConfig().pagecode;
class ContractRenewal extends Component {
    constructor(props) {
        super(props);
        if (props.use) {
            props.use.form('dataBase', 'dataBefore', 'dataAfter', 'dataBase_add')
            props.use.editTable('dataList', 'psnList')
            props.use.search('listquery')
        }

        this.config = {
            pagecode: pagecode,
            appcode: appcode
        };
        this.state = {
            json: {},
            buttons: [],
            isEmpty: true,
            pk_org: '',
            showMode: 'tableList', // 显示状态，默认是列表
            record: null,
            step: '0',
            info2: null,
            formEditOrigin: '',
            pk_psndoc_subs: '',
            oid: '',
            conditions: {},
            pageid: '',
            nodeRefs: {wpsview: null}
        }
        // if (window.location.href.match('localhost:3006')) {
        //     window.location.hash = '#/ifr?page=2019910144955114'
        // }
        props.createUIDom(this.config, (data) => {
            let template = data.template
            let oid = template.listquery.oid;
            this.initMeta(template,this);
            props.button.setButtons(data && data.button ? data.button : {});
            props.meta.setMeta(data && data.template ? data.template : {});
            this.setState({
                oid,
                pageid: data.template.pageid
            })
        });
    }
    componentWillMount () {
        let callback = (json, status, inlt) => {
            if (status) {
                this.setState({
                    json
                }, function () {
                    
                })//存json和inlt到页面state中并刷新页面
            }
        }
        this.props.MultiInit.getMultiLang({moduleId: 'cm6011', domainName: 'hrcm', callback})
    }
    componentDidMount() {
        this.props.button.setButtonVisible(['add','edit','delete','Viewbooklet','Effective','file','refresh','save','cancle','query'],false);
    }
    initMeta (template,opt) {
        let json = this.state.json
        let data = template['dataList'].items
        //添加附件
        data.push({
            attrcode: 'attachment',
            itemtype: 'customer',
            hyperlinkflag: false,
            label: json['cm6011-000062'], // 附件管理
            width: '100px',
            textAlign: 'center',
            visible: true,
            fixed: 'right',
            render(text, record, index) {
                return (
                    <span>
                        <i className="icon iconfont icon-fujianshenpi" onClick={opt.FileManagement.bind(opt, record)}></i>
                    </span>
                )
            }
        });
        data.push({
            attrcode: 'handleArea',
            itemtype: 'customer',
            hyperlinkflag: false,
            label: json['cm6011-000064'], /* 国际化处理： 附件管理*/
            width: '220px',
            textAlign: 'center',
            visible: true,
            fixed: 'right',
            render(text, record, index) {
                return (
                    <div>
                        <span style={{color: '#0073E1', cursor: 'pointer',marginRight: '12px'}}
                            onClick={opt.editOpreation.bind(opt,record)}
                        >
                            {/* 修改 */}
                            {json['cm6011-000067']}
                        </span>
                        <span style={{color: '#0073E1', cursor: 'pointer',marginRight: '12px'}}
                            onClick={opt.deleteOpreation.bind(opt,record)}
                        >
                            {/* 删除 */}
                            {json['cm6011-000065']}
                        </span>
                        <span style={{color: '#0073E1', cursor: 'pointer'}}
                            onClick={opt.viewbookletOpreation.bind(opt,record)}
                        >
                            {/* 合同文本 */}
                            {json['cm6011-000119']}
                        </span>
                    </div>
                )
            }
        });
        fixedCol(template['dataList'], [], json['cm6011-000152'])
        // 给合同编号添加超链接
        data.forEach((item, key) => {
            switch (item.attrcode) {
                case 'contractnum':
                    item.renderStatus = 'browse'
                    item.fixed = 'left'
                    item.render = (text, record, index) => {
                        return (
                            <span className="itemSpan" style={{color: '#007ace', cursor: 'pointer'}}
                                onClick={() =>{opt.toCardList(record)}}>
                            {record && record.values['contractnum'] && record.values['contractnum'].display || record.values['contractnum'].value}
                        </span>
                        );
                    };
                    break;
                case 'pk_majorcorp':
                    item.renderStatus = 'browse'
                    // item.width = '120px'
                    item.fixed = 'left'
                    item.render = (text, record, index) => {
                        return (
                            <span className="itemSpan">
                            {record && record.values['pk_majorcorp'] && record.values['pk_majorcorp'].display || record.values['pk_majorcorp'].value}
                        </span>
                        );
                    };
                    break;
                case 'pk_psndoc.code':
                    item.renderStatus = 'browse'
                    item.fixed = 'left'
                    // item.width = '120px'
                    item.render = (text, record, index) => {
                        return (
                            <span className="itemSpan">
                            {record && record.values['pk_psndoc.code'] && record.values['pk_psndoc.code'].display || record.values['pk_psndoc.code'].value}
                        </span>
                        );
                    };
                    break;
                case 'pk_psndoc.name':
                    item.renderStatus = 'browse'
                    item.fixed = 'left'
                    // item.width = '120px'
                    item.render = (text, record, index) => {
                        return (
                            <span className="itemSpan">
                            {record && record.values['pk_psndoc.name'] && record.values['pk_psndoc.name'].display || record.values['pk_psndoc.name'].value}
                        </span>
                        );
                    };
                    break;
                default:break;
            }
        });
    }
    // 传进表格的一行数据初始化表单数据显示
    initDataShow (pk_psndoc_sub, isEdit) {
            let paramObj = {
                pk_org: this.state.pk_org,
                pk_psndoc_sub
            }
            if (isEdit) {
                paramObj.isEdit = true
            }
            this.refs.cardList.initDataShow(paramObj)
    }
    // 调用头部翻页显示方法
    handlePageInfoChange (props, flag, status) {
        this.refs.header.handlePageInfoChange(props, flag, status)
    }
    // 跳转到卡片页面并显示数据
    toCardList (record, isEdit) {
        this.setBtnVisibleAndDisable('notShowSaveAndCancel')
        this.setState({
            showMode: 'cardList',
            record
        }, function () {
            let refs= this.refs
            let pk_psndoc_sub = record.values.pk_psndoc_sub.value
            refs['header'].setBackBtnVisible(true)
            let cardPaginationDis = true
            if (isEdit) {
                cardPaginationDis = false
            }
            refs.header.setCardPaginationVisible(cardPaginationDis, true, pk_psndoc_sub)
            this.initDataShow(pk_psndoc_sub, isEdit)
        })
    }
    // 设置卡片翻页容器显示隐藏
    setCardPaginationConDis (cardPaginationDis) {
        this.refs.header.setCardPaginationConDis(cardPaginationDis)
    }
    // 返回当前实在卡片状态还是列表状态
    returnListOrCard () {
        return this.state.showMode
    }
    // 按钮状态统一管理
    setBtnVisibleAndDisable (code) {
        let {button} = this.props
        switch (code) {
            // 只有保存和取消按钮
            case 'onlySaveAndCancelShow':
                button.setButtonVisible({
                    add: false, 
                    edit: false, 
                    delete: false, 
                    Viewbooklet: false, 
                    Effective: false,
                    file: false,
                    refresh: false,
                    query: false,
                    save: true,
                    cancle: true
                })
                break;
            // 不显示取消和保存按钮，其他都可以点击
            case 'notShowSaveAndCancel':
                button.setButtonVisible({
                    add: true, 
                    edit: true, 
                    delete: true, 
                    Viewbooklet: true, 
                    Effective: true,
                    file: true,
                    refresh: true,
                    save: false,
                    cancle: false,
                    query: false
                })
                break;
            case 'addDeleteMakeEffectRefreshQuery':
                button.setButtonVisible({
                    add: true, 
                    edit: false, 
                    delete: true, 
                    Viewbooklet: false, 
                    Effective: true,
                    file: false,
                    refresh: true,
                    save: false,
                    cancle: false,
                    query: true
                })
                break;
            case 'notShowAnyBtn':
                button.setButtonVisible({
                    add: false, 
                    edit: false, 
                    delete: false, 
                    Viewbooklet: false, 
                    Effective: false,
                    file: false,
                    refresh: false,
                    save: false,
                    cancle: false,
                    query: false
                })
                break;
            // 只有新增和刷新可以点击，其他按钮不可以
            case 'onlyAddAndRefreshNotDisabled':
                button.setButtonDisabled({
                    add: false, 
                    edit: true, 
                    delete: true, 
                    Viewbooklet: true, 
                    Effective: true,
                    file: true,
                    refresh: false,
                    save: true,
                    cancle: true,
                    query: false
                })
                break
            // 所有按钮都可以点
            case 'allBtnEnabled':
                button.setButtonDisabled({
                    add: false, 
                    edit: false, 
                    delete: false, 
                    Viewbooklet: false, 
                    Effective: false,
                    file: false,
                    refresh: false,
                    save: false,
                    cancle: false,
                    query: false
                })
                break
            // 只用新增可以点击
            case 'onlyAddBtnEnabled':
                button.setButtonDisabled({
                    add: false, 
                    edit: true, 
                    delete: true, 
                    Viewbooklet: true, 
                    Effective: true,
                    file: true,
                    refresh: true,
                    save: true,
                    cancle: true,
                    query: false
                })
                break 
            default: break;
        }
    }
    // 按钮操作函数
    BtnOperationFun (btnCode) {
        let refs = this.refs
        switch (btnCode) {
            case 'add':
                this.addOperation()
                break;
            case 'edit':
                this.editOpreation()
                break;
            case 'delete':
                this.deleteOpreation()
                break;
            case 'Viewbooklet':
                this.viewbookletOpreation()
                break;
            case 'Effective':
                this.makeEffectOpreation()
                break;
            case 'file':
                this.FileManagement()
                break;
            case 'refresh':
                this.refreshOpreation()
                break;
            case 'save':
                this.saveOpreation()
                break;
            case 'cancle':
                this.cancelOpreation()
                break;
            case 'query':
                this.queryOption()
                break;
                default:break;
        }
    }
    // 附件管理
    FileManagement (rowRecord) {
        let pk_psndoc_sub = ''
        if (this.state.showMode === 'tableList') {
            pk_psndoc_sub = rowRecord.values.pk_psndoc_sub.value
        } else {
            pk_psndoc_sub = this.state.record.values.pk_psndoc_sub.value
        }
        let callback = () => {
            this.refs.fileUpload.showUploader(pk_psndoc_sub)
        }
        let billPks = []
        billPks.push(pk_psndoc_sub)
        this.checkDataPermissionAction(billPks, 'attachment', callback)
    }
    // 生效操作
    makeEffectOpreation () {
        let selectCtrtpks = []
        let state = this.state
        const {json, pk_psndoc_subs, pk_org, conditions, showMode} = state
        let refs = this.refs
        let pageType = null
        if (showMode === 'tableList') {
            let {editTable} = this.props
            let selectRowsData = editTable.getCheckedRows('dataList')
            let selectRowLen = selectRowsData.length
            if (selectRowLen === 0) {
                toast({
                    color: 'warning',
                    content: json['cm6011-000120'] // 请至少选择一条记录
                });
                return false
            }
            selectCtrtpks = selectRowsData.map(function (item) {
                return item.data.values.pk_psndoc_sub.value
            })
            pageType = 'list'
        } else {
            selectCtrtpks.push(state.record.values.pk_psndoc_sub.value)
            pageType = 'card'
        }
        let dataObj = {
            baseParam: {step: state.step, info2: state.info2, pageType},
            selectCtrtpks
        }
        let callback = () => {
            ajax({
                url: '/nccloud/hrcm/make/MakeEffectiveAction.do',
                data: dataObj,
                success: (result) => {
                    if (result.success) {
                        this.setState({
                            step: result.data.step,
                            info2: result.data.info2
                        })
                        let title = json['cm6011-000043'] // 确认继续
                        if (result.data.step === '3') {
                            title = json['cm6011-000121'] // 确认生效
                        }
                        if (result.data.step !== '99') {
                            this.makeEffectAfterTips(result.data.msg, title)
                        } else {
                            toast({
                                color: 'success',
                                content: json['cm6011-000122'] // 生效成功
                            })
                            this.setState({
                                step: '0'
                            })
                            if (showMode === 'cardList') {
                                let allpks = cacheTools.get('allpks')
                                if (allpks.length > 1) {
                                    let pkIndex = null
                                    let indexNow = allpks.indexOf(selectCtrtpks[0])
                                    if (indexNow === allpks.length - 1) {
                                        pkIndex = 'length - 1'
                                    } else {
                                        pkIndex = indexNow
                                    }
                                    refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions, pkIndex)
                                } else {
                                    refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
                                    refs.cardList.EmptyAllFormValue()
                                }
                            } else {
                                refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
                            }
                        }
                    }
                }
            })
        }
        this.checkDataPermissionAction(selectCtrtpks, 'effect', callback)
    }
    // 刷新操作
    refreshOpreation () {
        if (this.state.showMode === 'tableList') {
            this.refs.tableList.queryTableList(this.state.pk_org)
        } else {
            this.toCardList(this.state.record)
            this.refs.tableList.queryTableList(this.state.pk_org)
        }
    }
    // 刷新列表操作
    refreshTableList () {
        const {pk_org, pk_psndoc_subs, conditions} = this.state
        this.refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
    }
    // 取消操作
    cancelOpreation () {
        let json = this.state.json
        promptBox({
            color: 'warning',
            title: json['cm6011-000043'], // 确认继续
            content: json['cm6011-000123'], // 是否确认取消
            noFooter: false,
            noCancelBtn: false,
            beSureBtnName: json['cm6011-000057'], // 是
            cancelBtnName: json['cm6011-000058'], // 否
            beSureBtnClick: this.beSureCancel.bind(this),
            hasCloseBtn:false
        })
    }
    // 点击生效之后的提示
    makeEffectAfterTips (message, title) {
        let json = this.state.json
        promptBox({
            color: 'warning',
            title: title, 
            content: message,
            noFooter: false,
            noCancelBtn: false,
            beSureBtnName: json['cm6011-000057'], // 是
            cancelBtnName: json['cm6011-000058'], // 否
            beSureBtnClick: this.makeEffectOpreation.bind(this),
            cancelBtnClick: this.cancelBtnClick.bind(this),  // 取消按钮点击调用函数,非必输
            // closeBtnClick: this.closeBtnClick.bind(this),
            hasCloseBtn:false
        })
    }
    // 点击取消按钮
    cancelBtnClick () {
        this.setState({
            step: '0'
        })
    }
    // 取消操作确认
    beSureCancel () {
        // 将form表单数据重置为原来的数据
        this.refs.cardList.resetMainFormData()
        if (this.state.formEditOrigin === 'list') {
            this.setBtnVisibleAndDisable('addDeleteMakeEffectRefreshQuery')
            this.setState({
                showMode: 'tableList'
            })
            this.refs['header'].setBackBtnVisible(false)
        } else {
            this.setCardPaginationConDis(true)
            this.setBtnVisibleAndDisable('notShowSaveAndCancel')
        }

    }
    // 选择组织或则删除组织之后的触发函数
    checkOrDeleteOrg (pk_org) {
        let pk_psndoc_subs = null
        if (localStorage.getItem('pageQueryParam')) {
            let pageQueryParam = JSON.parse(localStorage.getItem('pageQueryParam'))
            if (pageQueryParam.hasOwnProperty('extend')) {
                let extend = pageQueryParam.extend
                pk_psndoc_subs = extend.pk_psndoc_subs
                let copyPageQueryParam = JSON.parse(JSON.stringify(pageQueryParam))
                delete copyPageQueryParam.extend
                localStorage.setItem('pageQueryParam', JSON.stringify(copyPageQueryParam))
            }
        }
        if (pk_org) {
            this.setState({
                isEmpty: false,
                pk_org: pk_org,
                pk_psndoc_subs
            },function () {
                this.refs.tableList.queryTableList(pk_org, pk_psndoc_subs)
            })
            return false
        }
        this.setState({
            isEmpty: true
        }, function () {
            this.setBtnVisibleAndDisable('notShowAnyBtn')
        })
    }
    // 设置是显示列表还是显示卡片
    setCardListVisible (showMode) {
        this.setState({
            showMode 
        })

    }
    // 新增操作函数
    addOperation () {
        this.refs.addNew.setNewIncreasedDis(true)
    }
    // 编辑、删除、生效、附件校验接口
    checkDataPermissionAction (billPks, opFlag, callback) {
        ajax({
            url: '/nccloud/hrcm/agreement/CheckDataPermissionAction.do',
            data: {
                billPks,
                opFlag,
                nodeKey: 'contract'
            },
            success: (result) => {
                if (result.success) {
                    callback()
                }
            }
        })
    }
    // 编辑操作韩式
    editOpreation (rowRecord) {
        let refs = this.refs
        if (this.state.showMode === 'tableList') {
            let callback = () => {
                this.toCardList(rowRecord, true)
                this.setState({
                    formEditOrigin: 'list'
                })
                this.setBtnVisibleAndDisable('onlySaveAndCancelShow')
            }
            let pk_psndoc_sub = rowRecord.values.pk_psndoc_sub.value
            let billPks = []
            billPks.push(pk_psndoc_sub)
            this.checkDataPermissionAction(billPks, 'edit', callback)
        } else {
            let callback = () => {
                this.setCardPaginationConDis(false)
                refs.cardList.setMainFormEdit()
                this.setState({
                    formEditOrigin: 'card'
                })
                this.setBtnVisibleAndDisable('onlySaveAndCancelShow')
            }
            let record = this.state.record
            let pk_psndoc_sub = record.values.pk_psndoc_sub.value
            let billPks = []
            billPks.push(pk_psndoc_sub)
            this.checkDataPermissionAction(billPks, 'edit', callback)
        }
    }
    // 设置主表单编辑态
    setMainFormEdit () {
        this.refs.cardList.setMainFormEdit()
    }
    // 保存操作
    saveOpreation () {
        // 调用formView的修改保存方法
        let refs = this.refs
        refs.cardList.formViewEditSave()
    }
    // 生效之后刷新表格
    takeEffectAfterRefresh () {
        let refs = this.refs
        let state = this.state
        refs.tableList.queryTableList(state.pk_org)
    }
    // 确认删除的提示
    sureDeleteTips (paramObj) {
        let json = this.state.json
        promptBox({
            color: 'warning',
            title: json['cm6011-000041'], // 确认删除
            content: json['cm6011-000124'], // 确认删除吗？
            noFooter: false,
            noCancelBtn: false,
            beSureBtnName: json['cm6011-000057'], // 是
            cancelBtnName: json['cm6011-000058'], // 否
            beSureBtnClick: this.applyDeleteInterface.bind(this, paramObj),
            hasCloseBtn:false
        })
    }
    // 调用删除接口
    applyDeleteInterface (paramObj) {
        let state = this.state
        const {json, pk_psndoc_subs, pk_org, conditions, showMode} = state
        let refs = this.refs
        ajax({
            url: '/nccloud/hrcm/make/MakeDeleteAction.do',
            data: paramObj,
            success: (result) => {
                if (result.success) {
                    toast({
                        color: 'success',
                        content: json['cm6011-000004'] // 删除成功
                    });
                    if (showMode === 'cardList') {
                        let allpks = cacheTools.get('allpks')
                        if (allpks.length > 1) {
                            let pkIndex = null
                            let indexNow = allpks.indexOf(paramObj['allpks'][0])
                            if (indexNow === allpks.length - 1) {
                                pkIndex = 'length - 1'
                            } else {
                                pkIndex = indexNow
                            }
                            refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions, pkIndex)
                        } else {
                            refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
                            refs.cardList.EmptyAllFormValue()
                        }
                    } else {
                        refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
                    }
                }
            }
        })
    }
    // 删除操作
    deleteOpreation (rowRecord) {
        let json = this.state.json
        let {editTable} = this.props
        let isCard = false
        let allpks = []
        if (this.state.showMode === 'cardList') {
            isCard = true
            let pk_psndoc_sub = this.state.record.values.pk_psndoc_sub.value
            allpks.push(pk_psndoc_sub)
        } else {
            if (rowRecord) {
                let pk_psndoc_sub2 = rowRecord.values.pk_psndoc_sub.value
                allpks.push(pk_psndoc_sub2)
            } else {
                let selectRowsData = editTable.getCheckedRows('dataList')
                if (selectRowsData.length === 0) {
                    toast({
                        color: 'wrining',
                        content: json['cm6011-000125'] // 请选择要删除的数据
                    });
                    return false
                }
                allpks = selectRowsData.map(function (item) {
                    let pk_psndoc_sub = item.data.values.pk_psndoc_sub.value
                    return pk_psndoc_sub
                })
            }
        }
        let callback = () => {
            let paramObj = {
                pk_org: this.state.pk_org,
                modename: 'hi_psndoc_ctrt',
                isCard: isCard,
                allpks: allpks
            }
            this.sureDeleteTips(paramObj)
        }
        this.checkDataPermissionAction(allpks, 'delete', callback)
    }
    // 合同文本操作
    viewbookletOpreation (rowRecord) {
        let json = this.state.json
        if (IsMac(json['cm6011-000148'])) {
            return false
        }
        let pk_psndoc_subs = ''
        if (this.state.showMode === 'tableList') {
            pk_psndoc_subs = rowRecord.values.pk_psndoc_sub.value
        } else {
            pk_psndoc_subs = this.state.record.values.pk_psndoc_sub.value
        }
        let paramObj = {
            pk_org: this.state.pk_org,
            pk_psndoc_subs: pk_psndoc_subs
        }
        ajax({
            url: '/nccloud/hrcm/templet/ContractTextViewAction.do',
            data: paramObj,
            success: (result) => {
                if (result.success) {
                    if (this.state.showMode === 'tableList') {
                        this.state.nodeRefs.wpsview.openView([{data: rowRecord}], 'ct')
                    } else {
                        let formData = this.props.form.getAllFormValue('dataBase').rows;
                        this.state.nodeRefs.wpsview.openView(formData, 'ct')
                    }
                    // let origin = 'uclient://start/' + window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '')
                    // window.location.href = origin + result.data
                }
            }
        })
    }
    // 查询数据
    searchData = () => {
        const {pk_psndoc_subs, pk_org} = this.state
        let conditions = this.props.search.getQueryInfo('listquery',true);
        this.refs.tableList.queryTableList(pk_org, pk_psndoc_subs, conditions)
    }
    // 点击查询按钮
    queryOption () {
        let template = this.props.meta.getMeta();
        let { pk_org } = this.state;
        template["listquery"].items.map(item => {
             // 部门
             if (item.attrcode === 'pk_psnjob.pk_dept') {
                item.queryCondition = () => {
                    return {
                        'pk_hrorg': pk_org
                    }
                }
             }else if(item.attrcode === 'pk_conttext'){
                item.queryCondition = {
                    pk_org: pk_org,
                    GridRefActionExt: 'nccloud.web.hrcm.make.sqlbuilder.ContModelGridSqlBuilder'
                }
            }
        })
        this.props.meta.setMeta(template, () => {
            this.props.search.openAdvSearch('listquery', true);
        })
    }
    // 点击分页卡片时重置record
    setRecord = (record) => {
        this.setState({
            record
        })
    }
    queryTableList = () => {
        return this.refs.tableList.queryTableList(this.state.pk_org)
    }
    render() {
        const {delay=true, search} = this.props
        const {NCCreateSearch} = search
        const {oid, pageid, nodeRefs} = this.state
        return (
            <div className="contractRenewal nc-single-table nc-bill-card">
                <Header 
                    {...this.props} 
                    ref='header'
                    queryTableList={this.queryTableList}
                    BtnOperationFun={this.BtnOperationFun.bind(this)} 
                    checkOrDeleteOrg={this.checkOrDeleteOrg.bind(this)}
                    setCardListVisible={this.setCardListVisible.bind(this)}
                    initDataShow={this.initDataShow.bind(this)}
                    cancelOpreation={this.cancelOpreation.bind(this)}
                    setBtnVisibleAndDisable={this.setBtnVisibleAndDisable.bind(this)}
                    setRecord={this.setRecord}/>
                <div className="panelContent">
                    <div className="emptyCon" style={{display: this.state.isEmpty ? 'block' : 'none'}}>
                        <EmptyImg text={this.state.json['cm6011-000096']}/>
                    </div>
                    <div className="listCon" style={{display: this.state.isEmpty ? 'none' : 'block'}}>
                        <div style={{display: this.state.showMode === 'tableList' ? 'block' : 'none'}}>
                            <TableList 
                            {...this.props}
                            returnListOrCard={this.returnListOrCard.bind(this)}
                            ref="tableList"
                            setBtnVisibleAndDisable = {this.setBtnVisibleAndDisable.bind(this)}
                            toCardList={this.toCardList.bind(this)}
                            handlePageInfoChange={this.handlePageInfoChange.bind(this)}
                            setRecord={this.setRecord.bind(this)}/>
                        </div>
                        <div style={{display: this.state.showMode === 'tableList' ? 'none' : 'block'}}>
                            <CardList 
                            {...this.props}
                            pageid={pageid}
                            refreshOpreation={this.refreshOpreation.bind(this)}
                            setCardPaginationConDis={this.setCardPaginationConDis.bind(this)}
                            json={this.state.json}
                            refreshTableList={this.refreshTableList.bind(this)}
                            ref="cardList"
                            takeEffectAfterRefresh={this.takeEffectAfterRefresh.bind(this)} 
                            setBtnVisibleAndDisable={this.setBtnVisibleAndDisable.bind(this)}
                            handlePageInfoChange={this.handlePageInfoChange.bind(this)}/>
                        </div>
                    </div>
                </div>
                <FileUpload json={this.state.json} ref="fileUpload"/>
                <AddNew 
                ref="addNew"
                pkOrg={this.state.pk_org} 
                {...this.props}
                config={this.config}
                pageid={pageid}
                json={this.state.json}
                initDataShow={this.initDataShow.bind(this)}
                returnListOrCard={this.returnListOrCard.bind(this)}
                setMainFormEdit={this.setMainFormEdit.bind(this)}
                refreshTableList={this.refreshTableList.bind(this)}/>
                <div style={{display: "none"}}>
                    {
                        NCCreateSearch('listquery', {
                            clickSearchBtn: ()=>{ this.searchData() },
                            onlyShowAdvArea: false,
                            showAdvSearchPlanBtn: true,
                            saveSearchPlan: true,
                            oid: oid,
                            onlyShowSuperBtn: true
                        })
                    }
                </div>
                <WpsModal
                    {...this.props}
                    onRef ={ref => nodeRefs.wpsview = ref}
                    appcode={getAppPageConfig().appcode}
                    pk_org={{refpk: this.state.pk_org}}
                   />
            </div>
        );
    }
}
export default ContractRenewal